import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { ListService } from './services/list.service';
import { DetailsService } from './services/details.service';

import { AddComponent } from './components/add/add.component';
import { ListComponent } from './components/list/list.component';
import { DetailsComponent } from './components/details/details.component';

const routes: Routes = [
	{
		path: '',
		data: {
			title: '人员中心',
		},
		children: [
			{
				path: '',
				component: ListComponent,
				runGuardsAndResolvers: 'always',
				resolve: {
					list: ListService,
				},
			},
			{
				path: 'add',
				component: AddComponent,
				data: {
					title: '添加人员',
				},
			},
			{
				path: 'detail/:name',
				component: DetailsComponent,
				runGuardsAndResolvers: 'always',
				resolve: {
					personnel: DetailsService,
				},
				data: {
					title: '人员详情',
				},
			},
		],
	},
];

@NgModule({
	imports: [RouterModule.forChild(routes)],
	exports: [RouterModule],
})
export class PersonnelRoutingModule {}
